package es.xpt.ysf.commons.issues.model;

import java.util.Locale;


public abstract class Issue {
	public static final String defaultActionName = "ADD_REMARK";
	
	public enum IssueType { TASK, ERROR, WARN, INFO }
	
	public enum IssueStatus { NEW, IN_PROGRESS, CLOSED, RESOLVED, REOPENED }
	
	public enum IssueResolution { USER_RESOLVED, ACTION_RESOLVED, INVALID }
	
	public enum IssuePriority { P1, P2, P3, P4, P5 }

	private String name;
	private IssueType type;
	
	public Issue() {
	}
	
	public Issue(String name, IssueType type ) {
		this.name = name;
		this.type = type;
	}
		
	public abstract Object[] getParameters();
		
	public Object[] getParametersDetailDescription(Locale locale, Object[] parameters) {
		return parameters;
	}
		

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public IssueType getType() {
		return type;
	}

	public void setType(IssueType type) {
		this.type = type;
	}
	
	public String getMessageSubject(Locale locale, Object[] params) {
		return type + ": " + name;
	}
	
	public String getMessageBody(Locale locale, Object[] params) {
		String messageBody = "";
		if (params!=null && params.length>0) {
			for (Object obj:params) {
				if ( obj!=null )
					messageBody+=obj.toString()+"\n";
			}
		}
		return messageBody;
	}
		
}
